import Vue from 'vue'
import Router from 'vue-router'

Vue.use(Router)

/* Layout */
import Layout from '@/layout'

/**
 * Note: sub-menu only appear when route children.length >= 1
 * Detail see: https://panjiachen.github.io/vue-element-admin-site/guide/essentials/router-and-nav.html
 *
 * hidden: true                   if set true, item will not show in the sidebar(default is false)
 * alwaysShow: true               if set true, will always show the root menu
 *                                if not set alwaysShow, when item has more than one children route,
 *                                it will becomes nested mode, otherwise not show the root menu
 * redirect: noRedirect           if set noRedirect will no redirect in the breadcrumb
 * name:'router-name'             the name is used by <keep-alive> (must set!!!)
 * meta : {
    roles: ['admin','editor']    control the page roles (you can set multiple roles)
    title: 'title'               the name show in sidebar and breadcrumb (recommend set)
    icon: 'svg-name'/'el-icon-x' the icon show in the sidebar
    breadcrumb: false            if set false, the item will hidden in breadcrumb(default is true)
    activeMenu: '/example/list'  if set path, the sidebar will highlight the path you set
  }
 */

/**
 * constantRoutes
 * a base page that does not have permission requirements
 * all roles can be accessed
 */
export const constantRoutes = [
  {
    path: '/login',
    component: () => import('@/views/login/index'),
    hidden: true
  },

  {
    path: '/404',
    component: () => import('@/views/404'),
    hidden: true
  },

  {
    path: '/',
    component: Layout,
    redirect: '/dashboard',
    children: [{
      path: 'dashboard',
      name: 'Dashboard',
      component: () => import('@/views/dashboard/index'),
      meta: { title: '系统首页', icon: 'dashboard' },
      id:'1',
      hidden: true
    }]
  },
  {
    path: '/',
    component: Layout,
    redirect: '/merchant',
    children: [{
      path: 'merchant',
      name: 'Merchant',
      component: () => import('@/views/merchant/index'),
      meta: { title: '商户进件', icon: 'el-icon-s-shop' },
      id:'30',
      hidden: true
    }]
  },
  {
    path: '/',
    component: Layout,
    redirect: '/order',
    children: [{
      path: 'order',
      name: 'Order',
      component: () => import('@/views/order/order'),
      meta: { title: '课程订单', icon: 'el-icon-s-order' },
      id:'21',
      hidden: true
    }]
  },

  
  {
    path: '/configure',
    component: Layout,
    name: 'Configure',
    meta: { title: '配置管理', icon: 'el-icon-s-claim' },
    children: [
      {
        path: 'advertisement',
        name: 'Advertisement',
        component: () => import('@/views/configure/advertisement'),
        meta: { title: '广告设置', icon: '' },
        id:'23',
        hidden: true
      },
      {
        path: 'distribution',
        name: 'Distribution',
        component: () => import('@/views/configure/distribution'),
        meta: { title: '分销设置', icon: '' },
        id:'24',
        hidden: true
      },
      {
        path: 'label',
        name: 'Label',
        component: () => import('@/views/configure/label'),
        meta: { title: '标签管理', icon: '' },
        id:'25',
        hidden: true
      },
      {
        path: 'huiyiAdmin',
        name: 'HuiyiAdmin',
        component: () => import('@/views/configure/huiyiAdmin'),
        meta: { title: '会议管理', icon: '' },
        id:'26',
        hidden: true
      },
      {
        path: 'gwxx',
        name: 'Gwxx',
        component: () => import('@/views/configure/gwxx'),
        meta: { title: '岗位学习', icon: '' },
        id:'27',
        hidden: true
      },
      {
        path: 'agreement',
        name: 'Agreement',
        component: () => import('@/views/configure/agreement'),
        meta: { title: '内容管理', icon: '' },
        id:'28',
        hidden: true
      },
      {
        path: 'feedback',
        name: 'Feedback',
        component: () => import('@/views/configure/feedback'),
        meta: { title: '反馈列表', icon: '' },
        id:'29',
        hidden: true
      }
    ]
  },
  {
    path: '/appAdmin',
    component: Layout,
    name: 'AppAdmin',
    meta: { title: '应用管理', icon: 'el-icon-menu' },
    children: [
      {
        path: 'tgList',
        name: 'Tglist',
        component: () => import('@/views/appAdmin/tgList'),
        meta: { title: '推广列表', icon: '' },
        id:'32',
        hidden: true
      },
      {
        path: 'fws',
        name: 'Fws',
        component: () => import('@/views/appAdmin/fws'),
        meta: { title: '服务商列表', icon: '' },
        id:'33',
        hidden: true
      },
      {
        path: 'hhr',
        name: 'Hhr',
        component: () => import('@/views/appAdmin/hhr'),
        meta: { title: '合伙人列表', icon: '' },
        id:'34',
        hidden: true
      },
      {
        path: 'jfzx',
        name: 'Jfzx',
        component: () => import('@/views/appAdmin/jfzx'),
        meta: { title: '交付中心列表', icon: '' },
        id:'35',
        hidden: true
      },
      {
        path: 'teacher',
        name: 'Teacher',
        component: () => import('@/views/appAdmin/teacher'),
        meta: { title: '教师管理', icon: '' },
        id:'36',
        hidden: true
      },
      {
        path: 'user',
        name: 'User',
        component: () => import('@/views/appAdmin/user'),
        meta: { title: '家长管理', icon: '' },
        id:'37',
        hidden: true
      },
      {
        path: 'curriculum',
        name: 'Curriculum',
        component: () => import('@/views/appAdmin/curriculum'),
        meta: { title: '课程管理', icon: '' },
        id:'38',
        hidden: true
      }
    ]
  },
  {
    path: '/userAdmin',
    component: Layout,
    name: 'UserAdmin',
    meta: { title: '用户权限管理', icon: 'el-icon-user-solid' },
    children: [
      {
        path: 'user',
        name: 'User',
        component: () => import('@/views/userAdmin/user'),
        meta: { title: '用户管理', icon: '' },
        id:'3',
        hidden: true
      },
      {
        path: 'menu',
        name: 'Menu',
        component: () => import('@/views/userAdmin/menu'),
        meta: { title: '菜单管理', icon: '' },
        id:'4',
        hidden: true
      },
      {
        path: 'jurisdiction',
        name: 'Jurisdiction',
        component: () => import('@/views/userAdmin/jurisdiction'),
        meta: { title: '角色权限', icon: '' },
        id:'5',
        hidden: true
      }
    ]
  },
  {
    path: '/financeAdmin',
    component: Layout,
    name: 'FinanceAdmin',
    meta: { title: '财务管理', icon: 'el-icon-s-marketing' },
    children: [
      {
        path: 'fwsCaiwu',
        name: 'FwsCaiwu',
        component: () => import('@/views/financeAdmin/fwsCaiwu'),
        meta: { title: '服务商财务列表', icon: '' },
        id:'40',
        hidden: true
      },
      {
        path: 'hhrCaiwu',
        name: 'HhrCaiwu',
        component: () => import('@/views/financeAdmin/hhrCaiwu'),
        meta: { title: '合伙人财务列表', icon: '' },
        id:'41',
        hidden: true
      },{
        path: 'jfzxCaiwu',
        name: 'JfzxCaiwu',
        component: () => import('@/views/financeAdmin/jfzxCaiwu'),
        meta: { title: '交付中心财务列表', icon: '' },
        id:'42',
        hidden: true
      },{
        path: 'jsCaiwu',
        name: 'JsCaiwu',
        component: () => import('@/views/financeAdmin/jsCaiwu'),
        meta: { title: '教师财务列表', icon: '' },
        id:'43',
        hidden: true
      },
    ]
  },
  // 404 page must be placed at the end !!!
  { path: '*', redirect: '/404', hidden: true }
]

const createRouter = () => new Router({
  // mode: 'history', // require service support
  scrollBehavior: () => ({ y: 0 }),
  routes: constantRoutes
})

const router = createRouter()

// Detail see: https://github.com/vuejs/vue-router/issues/1234#issuecomment-357941465
export function resetRouter() {
  const newRouter = createRouter()
  router.matcher = newRouter.matcher // reset router
}

export default router
